#include "utils.h"


void dump_mem(uint8_t* mem, uint16_t length)
{

	int i = 0;
	uint8_t tmp;

	for (; i < length; i++) {
		tmp = mem[i] >> 4;
		if (tmp < 10) {
			putchar(tmp + '0');
		}
		else {
			putchar(tmp - 10 + 'A');
		}

		tmp = mem[i] & 0x0f;
		if (tmp < 10) {
			putchar(tmp + '0');
		}
		else {
			putchar(tmp - 10 + 'A');
		}

		putchar(32);
	}

	putchar('\n');
}


void dump_stream(FILE* stream, uint8_t* mem, uint16_t length)
{
	int i = 0;
	uint8_t tmp;
	for (; i < length; i++) {
		tmp = mem[i] >> 4;
		if (tmp < 10) {
			//putchar(tmp + '0');
			fputc(tmp + '0', stream);
		}
		else {
			fputc(tmp - 10 + 'A', stream);
			//putchar(tmp - 10 + 'A');
		}

		tmp = mem[i] & 0x0f;
		if (tmp < 10) {
			//putchar(tmp + '0');
			fputc(tmp + '0', stream);
		}
		else {
			//putchar(tmp - 10 + 'A');
			fputc(tmp - 10 + 'A', stream);
		}

		//putchar(32);
		fputc(32, stream);
	}

	//putchar('\n');
	fputc('\n', stream);
}